//
//  ST_MeetYouHeader.swift
//  btvideo
//
//  Created by mac on 2020/8/3.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwiftyAttributes


class ST_MeetYouHeader: UIView {
    
    static let height = 40.cgFloat
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
//            make.edges.equalToSuperview().inset(UIEdgeInsets.init(top: 0, left: 15, bottom: 0, right: 0))
            
            make.top.bottom.equalToSuperview()
            make.left.equalToSuperview().offset(15)
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate lazy var titleLabel:UILabel = {
       let control = UILabel()
        
        return control
    }()
    
    var number = (key:"",value:0) {
        didSet{
            
            let str = "有".withAttributes([Attribute.font(UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.semibold)),.textColor(UIColor.init(hex: 0x333333)!)])
            
            let numberStr = number.value.string.withAttributes([Attribute.font(UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.semibold)),.textColor(UIColor.init(hex: 0xFEC207)!)])
            
            let suffixStr = "人\(number.key)你".withAttributes([Attribute.font(UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.semibold)),.textColor(UIColor.init(hex: 0x333333)!)])
         
            str.append(numberStr)
            str.append(suffixStr)
            
            self.titleLabel.attributedText = str
            
        }
    }
    
}


class MeetYouFooter: UIView {
    
    static let height = 55.cgFloat
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
            make.edges.equalToSuperview().inset(UIEdgeInsets.init(top: 15, left: 15, bottom: 0, right: 0))
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate lazy var titleLabel:UILabel = {
       let control = UILabel()
        control.numberOfLines = 0
        return control
    }()
    
    var number = (key:"",value:0) {
        didSet{
            
            let p = NSMutableParagraphStyle()
            p.lineSpacing = 3
            p.alignment = .center
            
            let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 14),.foregroundColor: UIColor(red: 0.38, green: 0.4, blue: 0.44, alpha: 1),.paragraphStyle:p]
            
            let strSubAttr2: [NSMutableAttributedString.Key: Any] = [.font: UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.medium),.foregroundColor: UIColor(red: 1, green: 0.76, blue: 0.03,alpha:1.000000)]
            
            
            let attrString = NSMutableAttributedString(string: "一共有")
            
            attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
            
            
            let numberString = NSMutableAttributedString(string: number.value.string)
            
            numberString.addAttributes(strSubAttr2, range: NSRange(location: 0, length: numberString.length))
            
            let pString = NSMutableAttributedString(string: number.key)
            
            pString.addAttributes(attr, range: NSRange(location: 0, length: pString.length))
            
            attrString.append(numberString)
            
            attrString.append(pString)
            
            self.titleLabel.attributedText = attrString
            
        }
    }
    
}

